﻿using System;
using System.Linq;
using System.Collections.Generic; 
using System.Data;
using System.Text;
using Matrix.Common.Utility;
using Matrix.MaKaYunShang.Model;
using Matrix.MaKaYunShang.DAL;

namespace Matrix.MaKaYunShang.BLL
{
	public partial class OrderDetailBLL : BaseBLL<OrderDetailBLL>
	{
		#region 默认方法
		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(OrderDetail model)
		{
			return OrderDetailDAL.Instance.Add(model);		
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(OrderDetail model)
		{
			return OrderDetailDAL.Instance.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{			
			return OrderDetailDAL.Instance.Delete(Id);
		}
				/// <summary>
		/// 批量删除一批数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			return OrderDetailDAL.Instance.DeleteList(Idlist );
		}
		
		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public OrderDetail GetModel(int Id)
		{
			var ds = OrderDetailDAL.Instance.GetModel(Id);
            return ds == null ? null : ServicesHelper.DataSetToIList<OrderDetail>(ds).ToList()[0];
		}
		
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<OrderDetail> GetModelList(string strWhere = null)
		{
			var ds = OrderDetailDAL.Instance.GetList(strWhere);
			return ServicesHelper.DataSetToIList<OrderDetail>(ds).ToList();
		}
		#endregion
		
		#region 扩展方法

	    /// <summary>
	    /// 通过ORDERID获取订单详情列表
	    /// </summary>
	    public List<OrderDetail> GetOrderDetailListByOrderId(int orderId)
	    {
	        return OrderDetailDAL.Instance.GetOrderDetailListByOrderId(orderId);
	    }

        /// <summary>
        /// 根据时间段获取用户已获得的赠品数量
        /// </summary>
        /// <param name="consumerId">用户ID</param>
        /// <param name="commodityGiftId">赠品ID</param>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <returns>返回时间段内用户已获得的赠品数量</returns>
        /// <remarks>2016-09-22 万乐园 创建</remarks>
        public int GetOrderGiftCountByTime(int consumerId, int commodityGiftId, string startTime, string endTime)
        {
            return OrderDetailDAL.Instance.GetOrderGiftCountByTime(consumerId, commodityGiftId, startTime, endTime);
        }

	    #endregion
	}
}